package day08.ZiXi;

import day06.ZiXi.Student;

import java.util.ArrayList;
import java.util.Iterator;

public class CeShi {
    public static void main(String[] args) {
        //创建集合
        ArrayList<Student> list = new ArrayList<>();
        //创建对象
        Student s1 = new Student("大雄",13);
        Student s2 = new Student("小夫",13);
        Student s3 = new Student("胖虎",13);
        Student s4 = new Student("静香",13);
        //添加元素
        list.add(s1);
        list.add(s2);
        list.add(s3);
        list.add(s4);
        Iterator<Student> it = list.iterator();
        //迭代器方法进行遍历
        while (it.hasNext()){
            Student s = it.next();
            System.out.println(s);
        }
        System.out.println("----------------------------------------------");
        //增强Fo方法进行遍历
        for (Student student : list) {
            System.out.println(student);
            
        }

    }
}
